<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.model.Student" %>  
<%@ page import="com.control.StudentControl" %>  
<%@ page import="com.control.DormControl" %>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String stu_num=request.getParameter("number");
String stu_pwd=request.getParameter("password");
String stu_name=request.getParameter("name");
String stu_sex=request.getParameter("sex");
String stu_birth=request.getParameter("birth");
String stu_tel=request.getParameter("tel");
String stu_college=request.getParameter("college");
String stu_major=request.getParameter("major");
int stu_building_id=Integer.parseInt(request.getParameter("building"));
String stu_dorm_name=request.getParameter("dorm");
Student st=new Student();
StudentControl sc=new StudentControl();
st.setStu_num(stu_num);
st.setStu_pwd(stu_pwd);
st.setStu_name(stu_name);
st.setStu_sex(stu_sex);
st.setStu_birth(stu_birth);
st.setStu_tel(stu_tel);
st.setStu_college(stu_college);
st.setStu_major(stu_major);
DormControl dc = new DormControl();
int stu_dorm_id = dc.getDormId(stu_dorm_name, stu_building_id);
st.setStu_dorm_id(stu_dorm_id);
boolean flag = Boolean.parseBoolean(request.getParameter("leader"));
//System.out.println(flag);
if(sc.insertStu(st,flag))
{
	%>
	<script>
	if(window.confirm("添加成功，是否继续添加学生？"))
		window.location.href="student_insert.jsp";
	else
		window.location.href="studentInfo_show.jsp";
	</script>
	<%}else{ %>
	<script>
	alert("添加失败！");
	window.location.href="studentInfo_show.jsp";
	</script>
	<%} %>
</body>
</html>